In [1]:
import lasio
import datetime
import numpy
import os
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
depths = numpy.arange(10, 50, 0.5)
fake_curve = numpy.random.random(len(depths))
fake_curve[-10:] = numpy.nan # Add some null values at the bottom
In [3]:
plt.plot(depths, fake_curve)
Out[3]:
In [4]:
l = lasio.LASFile()
In [5]:
l.header
Out[5]:
Let's add some information to the header:
First, let's change the date.
In [6]:
l.well.DATE = str(datetime.datetime.today())
Next, let's make a new item in the ~Parameters section for the operator. To do this we need to make a new HeaderItem:
In [7]:
l.params['ENGI'] = lasio.HeaderItem("ENGI", "", "kinverarity@hotmail.com", "Creator of this file...")
And finally, add some free text to the ~Other section:
In [8]:
l.other = "Example of how to create a LAS file from scratch using lasio"
In [9]:
l.add_curve('DEPT', depths, unit='m')
l.add_curve('FAKE_CURVE', fake_curve, descr='fake curve')
In [10]:
fn = "scratch_example_v2.las"
with open(fn, mode="w") as f: # Write LAS file to disk
l.write(f)
and let's see if that worked
In [11]:
with open(fn, mode="r") as f: # Show the result...
print(f.read())
In [13]:
plt.plot(l['DEPT'], l['FAKE_CURVE'])
Out[13]:
In [14]:
os.remove(fn)
In [ ]: